/*
 ============================================================================
 Name		: Server.cpp
 Author	  : wangli@opi-corp.com
 Copyright   : Your copyright notice
 Description : Exe source file
 ============================================================================
 */

#include "Server.h"
#include "CPanicServer.h"
#include "Service.h"

#include <e32base.h>
#include <e32debug.h>
#include <e32std.h>


LOCAL_C void MainL()
{
    CPanicServer* pServer = CPanicServer::NewL(CActive::EPriorityHigh);
    CleanupStack::PushL(pServer);
    
    pServer->StartL(KServiceName);
    
    CActiveScheduler::Start();
    CleanupStack::PopAndDestroy(pServer);
}

LOCAL_C void DoStartL()
{
    // Create active scheduler (to run active objects)
    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
    CleanupStack::PushL(scheduler);
    CActiveScheduler::Install(scheduler);

    MainL();

    // Delete active scheduler
    CleanupStack::PopAndDestroy(scheduler);
}

//  Global Functions

GLDEF_C TInt E32Main()
{
    // Create cleanup stack
    __UHEAP_MARK;
    CTrapCleanup* cleanup = CTrapCleanup::New();
    

    // Run application code inside TRAP harness, wait keypress when terminated
    TRAP_IGNORE(DoStartL());

    delete cleanup;
    __UHEAP_MARKEND;
    return KErrNone;
}

